<?php defined('SYSPATH') or die('No direct script access.');

/**
 * @example 三种情况
 *
 */
class Model_Wizard extends Model_Database {

	public function get_table_list()
	{
		$result = $this->_db->list_tables();
		$len = strlen($this->_db->table_prefix());
		foreach ($result as &$value)
			$value = substr($value, $len);
		return $result;
	}

	public function get_column_list($table_name1)
	{
		$table_name = array();$result = array();
		foreach(func_get_args() as $v)
			$table_name = array_merge($table_name, to_array($v));
		foreach ($table_name as $value)
		{
			$result[$value]['columns'] = $this->_db->list_columns($value);
			$result[$value]['primary_key'] = key($result[$value]['columns']);
			foreach ($result[$value]['columns'] as $col)
				if ($col['key'] == 'PRI') {
					$result[$value]['primary_key'] = $col['column_name'];
					break;
				}
		}
		return $result;
	}
}